<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\Common\model;

class LongbingUserInfo extends \app\BaseModel
{
    protected $name = "longbing_card_user_info";
    public function getUser($filter)
    {
        $result = $this->where($filter)->find();
        if(!empty($result)) {
            $result = $result->toArray();
        }
        return $result;
    }
    public function getStaff($fans_id, $uniacid)
    {
        $result = $this->alias("card")->field(["card.*", "job.name as job_name"])->join("longbing_card_job job", "card.job_id = job.id", "LEFT")->where([["card.fans_id", "=", $fans_id], ["card.uniacid", "=", $uniacid]])->find();
        if(!empty($result)) {
            $result = $result->toArray();
        }
        return $result;
    }
    public function updateUser($filter, $data)
    {
        $data["update_time"] = time();
        $result = $this->where($filter)->update($data);
        return !empty($result);
    }
    public function getUserCount($filter = [])
    {
        $count = $this->where($filter)->count();
        return $count;
    }
    public function getOneStaff($uniacid = 7777)
    {
        $where[] = ["uniacid", "=", $uniacid];
        $where[] = ["is_staff", "=", 1];
        $where[] = ["is_default", "=", 1];
        $where[] = ["fans_id", "<>", 0];
        $result = $this->where($where)->order("auto_count asc")->field("id,fans_id as staff_id")->find();
        if(!empty($result)) {
            $result = $result->toArray();
            $this->where(["id" => $result["id"]])->inc("auto_count");
        }
        return $result;
    }
    public function getCount($filter)
    {
        $result = $this->where($filter)->count();
        return $result;
    }
}

?>